#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

int N, A, B;
bool isvisited[210];
int path[210];
int floors[210];

void bfs()
{
    queue<int> q;
    q.push(A);
    isvisited[A] = true;
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        if (u == B)
        {
            cout << path[u] << endl;
            return ;
        }
        for (int i = 0; i < 2; i++)
        {
            int tempfloor = u;
            if (i == 0)
            {
                tempfloor -= floors[u];
            }
            else
            {
                tempfloor += floors[u];
            }
            if (tempfloor >= 1 && tempfloor <= N && !isvisited[tempfloor])
            {
                q.push(tempfloor);
                path[tempfloor] = path[u] + 1;
                isvisited[tempfloor] = true;
            }
        }
    }
    cout<<-1<<endl;
    return ;
}

int main()
{
    cin >> N >> A >> B;
    for (int i = 1; i <= N; i++)
    {
        cin >> floors[i];
    }
    bfs();
    //system("pause");
    return 0;
}